def solution():
def ceil_divide(a, b):
return (a+b-1)//b
n, m, d = list(map(int, input().split()))
c = list(map(int, input().split()))
if ceil_divide(n-sum(c), m+1) >= d:
return "NO"
q, r = divmod(n-sum(c), m+1)
result = [0]*n
j = 0
for i in range(m):
j += q+int(i < r)
for _ in range(min(c[i],n-j)):
result[j] = i+1
j += 1
j += q+int(m < r)
assert(j == n)
return f'YES\n{" ".join(map(str, result))}'
print(solution())
#include <bits/stdc++.h>
#define int long long
using namespace std;
main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int n, m, d;
cin >> n >> m >> d;
int c[m + 5], s = 0;
for(int i = 1; i <= m; ++i) {
cin >> c[i];
s += c[i];
}
int ans[n + 5] = {0}, h = 0, j = 1;
for(int i = 1; i <= n; ++i) {
if(n - i + 1 == s) {
int k = 0;
for(int z = i; z <= n; ++z) {
k ++;
ans[z] = j;
if(k == c[j]) {
j ++;
k = 0;
}
}
break;
}
if(i == h + d) {
if(j == m + 1) {
cout << "NO";
return 0;
}
for(int z = i; z < i + c[j]; ++z) {
ans[z] = j;
}
i += c[j] - 1;
h = i;
s -= c[j];
j ++;
}
}
cout << "YES\n";
for(int i = 1; i <= n; ++i) {
cout << ans[i] << " ";
}
}
733. Flood Fill | 206. Reverse Linked List |
83. Remove Duplicates from Sorted List | 116. Populating Next Right Pointers in Each Node |
145. Binary Tree Postorder Traversal | 94. Binary Tree Inorder Traversal |
101. Symmetric Tree | 77. Combinations |
46. Permutations | 226. Invert Binary Tree |
112. Path Sum | 1556A - A Variety of Operations |
136. Single Number | 169. Majority Element |
119. Pascal's Triangle II | 409. Longest Palindrome |
1574A - Regular Bracket Sequences | 1574B - Combinatorics Homework |
1567A - Domino Disaster | 1593A - Elections |
1607A - Linear Keyboard | EQUALCOIN Equal Coins |
XOREQN Xor Equation | MAKEPAL Weird Palindrome Making |
HILLSEQ Hill Sequence | MAXBRIDGE Maximise the bridges |
WLDRPL Wildcard Replacement | 1221. Split a String in Balanced Strings |
1002. Find Common Characters | 1602A - Two Subsequences |